package com.lzw.service.impl.superAdmin;

import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import com.lzw.mapper.superAdmin.StockManageMapper;
import com.lzw.pojo.StockEntries;
import com.lzw.pojo.Suppliers;
import com.lzw.service.superAdmin.StockManageService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.time.LocalDate;
import java.util.List;

@Service
public class StockManageServiceImpl implements StockManageService {

    @Autowired
    private StockManageMapper stockManageMapper;

    @Override
    public List<StockEntries> list(Integer pageNum, Integer pageSize, String medicine, LocalDate entryDate, String supplier) {
        PageHelper.startPage(pageNum,pageSize);
        List<StockEntries> list = stockManageMapper.list(medicine, entryDate,supplier);
        Page<StockEntries> stockEntries = (Page<StockEntries>) list;
        return stockEntries;
    }

    @Override
    public void delete(List<Integer> ids) {
        stockManageMapper.delete(ids);
    }

    @Override
    public void add(StockEntries stockEntries) {
        stockEntries.setEntryDate(LocalDate.now());
        stockManageMapper.add(stockEntries);
    }

    @Override
    public void update(StockEntries stockEntries) {
        stockManageMapper.update(stockEntries);
    }
}
